<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>

<sql:query var="rs" dataSource="jdbc/bookzone">
    select BOOKS.*, PRICES.book_price FROM BOOKS JOIN PRICES ON BOOKS.book_id = PRICES.book_id AND BOOKS.book_id = <%= this.product_id%> 
</sql:query>

<c:forEach var="row" items="${rs.rows}">
    <form method="POST" action="add_to_cart">
    <div class="bookItem">
        <div class="productImage"><img src="${row.img_url}" border="0"/></div>
            <div class="productData">
                <div class="productTitle">
                    <a href="/details.jsp?id=${row.book_id}">${row.title}</a>
                    <span class="authors">${row.author1}</span>
            </div>
                <div class="price">
                    Price:
                    <span class="priceValue">${row.book_price}$</span>
                </div>
                <%
                    if((String)session.getAttribute("email") != null){
                %>
                        <input type="hidden" name="product_id" value="<%=this.product_id %>" >
                        <input type="submit" value="Add to cart"> 
                        <%--<span><a href="add_to_cart/?id=<%=this.product_id%>">Add to cart</a> </span>--%>
                <%
                    }
                %>
        </div>
    </div>
    </form>
</c:forEach>
